using System;

namespace _1023
{
    public static class Bubble
    {
        public static void Sort(int[] a)
        {
            for (int i = 0; i < a.Length - 1; i++)
            {
                bool swapped = false;
                for (int j = 0; j < a.Length - 1 - i; j++)
                    if (a[j] > a[j + 1])
                    {
                        (a[j], a[j + 1]) = (a[j + 1], a[j]);
                        swapped = true;
                    }
                if (!swapped) break;
            }
        }

        // 作业 1 统一入口
        public static void TestPrint1()
        {
            int[] arr = { 5, 2, 9, 1, 5, 6 };
            Console.WriteLine("Original: " + string.Join(", ", arr));
            Sort(arr);
            Console.WriteLine("Sorted  : " + string.Join(", ", arr));
        }
    }
}